Variables are created through a variable declaration. The variable declaration associates the variable name identifier with a specific data type. This data type tells the VectorScript compiler how much memory storage will need to be allocated for the data that will be stored in that location.
For simple data and array types, these declarations occur in one location in the script, known as the VAR block. This area of the script is located at the beginning of the main program block, prior to the main body of script code, and is indicated by the
VAR keyword. The
VAR block is the only location where variables can be declared; unlike languages such as Basic or JavaScript, variables cannot be declared in the source code of the script.
VectorScript uses the information provided by the VAR block to allocate memory needed for the script to execute properly. In the example below, two variables are declared to provide data storage for the script:
Note that values are not actually assigned to the variables declared in the VAR block. The actual assignment of values into the variable storage locations occurs in the body of the script. The purpose of the
VAR block is to define storage requirements, not to define data.